//
//  UFOBaseModel.m
//  unrivalledForUniverse
//
//  Created by dllo on 1/8/16.
//  Copyright © 2016 dllo. All rights reserved.
//

#import "UFOBaseModel.h"

@implementation UFOBaseModel

- (void)dealloc
{
    [_mId release];
    [super dealloc];
}

- (instancetype)initWithDic:(NSMutableDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}


+ (instancetype)baseModelWithDic:(NSMutableDictionary *)dic
{
    id obj = [[[self class] alloc] initWithDic:dic];
    return [obj autorelease];
}

+ (NSMutableArray *)baseModelWithArr:(NSMutableArray *)arr
{
    NSMutableArray *modelArr = [NSMutableArray array];
    for (NSMutableDictionary *dic in arr) {
        @autoreleasepool {
            id model = [[self class] baseModelWithDic:dic];
            [modelArr addObject:model];
        }
    }
    return modelArr;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    if ([key isEqualToString:@"id"]) {
        self.mId = value;
    }
}


@end
